<template>
	<view class="mainpadding">
		<view class="ffffff  radius flexleft" style="padding: 18rpx 30rpx;">
			<view class="margin_right">
				<u-icon name="search" color="#999999" size="28"></u-icon>
			</view>
			<input placeholder="输入关键词以搜索" type="text" v-model="keywords" confirm-type="search" @confirm="init"/>
		</view>
		<view class="mainpadding ffffff radius margin_top" v-for="item in list.data" :key="item.id">
			<view class="flexbetween">
				<view class="">
					<view class="sanshier fonweight xiaohei">{{item.username}}</view>
					<view class="ershil margin_top2 xiaohui">{{item.mobile}}</view>
				</view>
				<view class="xubtn flexcenter" @click="zhipai(item.id)">选择</view>
			</view>
			<view class="xiaohui margin_top" v-for="(ite,inde) in item.tasklist" :key="inde">{{ite}}</view>
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				keywords:"",
				listid:""
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.init()
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					keywords:this.keywords
				}
				let url = '/api/admintask/userIndex'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if(!list.last_page){
					return false
				}
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			zhipai(id){
				httpRequest.request('/api/admintask/zpusersj', 'GET', {
					user_id: id,
					id:this.listid
				}).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.xubtn{
	width: 135rpx;
	height: 71rpx;
	background: rgba(255,133,5,0.1);
	font-weight: 500;
	font-size: 28rpx;
	color: #FF8505;
	border-radius: 36rpx 36rpx 36rpx 36rpx;
}
</style>
